//
//  ProblemUpViewController.m
//  Utils
//
//  Created by enghou on 2018/4/17.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "ProblemUpViewController.h"
#import "ManipulatorViewController.h"
#import "SubEnterpriseViewController.h"
#import "ManipulatorItemModel.h"
@interface ProblemUpViewController ()

@end

@implementation ProblemUpViewController

-(NSString *)typeId{
    return @"50";
}

- (void)viewDidLoad {
    [super viewDidLoad];
}

-(NSDictionary *)param{
    if ([self.manipulator_id length] == 0) {
        [self alertSome:@"请选择主办单位!"];
        return nil;
    }
    if ([self.subEnterpriseId length] == 0) {
        [self alertSome:@"请选择抄告单位!"];
        return nil;
    }
    if ([self.suggestionField.text length] == 0) {
        [self alertSome:@"请输入办理意见!"];
        return nil;
    }
    return @{@"issueStepId":self.stepId,@"logNew.targeOrg.id":self.manipulator_id,@"tellOrgIds":self.subEnterpriseId,@"logNew.content":self.suggestionField.text};
}

-(void)pushToManipulator{
    ManipulatorViewController *vc = [[ManipulatorViewController alloc]init];
    vc.modelClsName = @"ManipulatorItemModel";
    vc.path = kUpManipulator;
    vc.theDelete = self;
    vc.stepId = self.stepId;
     [(BaseViewController *)self.theDelete push:vc];
}

- (IBAction)showFilePicker:(id)sender {
    [super showFilePicker:sender];
}

-(void)pushToSubEnterprise{
    SubEnterpriseViewController *vc = [[SubEnterpriseViewController alloc]init];
    vc.modelClsName = @"ManipulatorItemModel";
    vc.path = kUpSubEnterprise;
    vc.theDelete = self;
    vc.stepId = self.stepId;
    [(BaseViewController *)self.theDelete push:vc];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        [self showActions];
    }else if (indexPath.row == 1) {
        [self pushToManipulator];
    }else if (indexPath.row == 2){
        [self pushToSubEnterprise];
    }
}

-(void)fetchArray:(NSArray *)array{
    NSMutableArray *ids = [NSMutableArray array];
    NSMutableArray *names = [NSMutableArray array];
    for (ManipulatorItemModel *model in array) {
        [ids addObject:model.code];
        [names addObject:model.name];
    }
    self.subEnterpriseId = [ids componentsJoinedByString:@","];
    self.subEnterpriseField.text = [names componentsJoinedByString:@","];
}

-(void)fetchModel:(id)model{
    ManipulatorItemModel *m = (ManipulatorItemModel *)model;
    self.manipulator_id = m.code;
    self.manipulatorField.text = m.name;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
